package fr.pentalog.ctc.service.impl;

import java.util.ArrayList;
import java.util.List;

import javax.annotation.Resource;
import javax.jws.WebService;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import fr.pentalog.ctc.dao.ItemDao;
import fr.pentalog.ctc.model.ItemServiceIn;
import fr.pentalog.ctc.model.ItemServiceOut;
import fr.pentalog.ctc.model.record.ItemRecord;
import fr.pentalog.ctc.service.ItemService;


/**
 * @author Danut Chindris
 * @since September 14, 2013
 */

@WebService(endpointInterface = "fr.pentalog.ctc.service.ItemService")
@Service
public class ItemServiceImpl implements ItemService {

	@SuppressWarnings("unused")
	private static final Logger logger = LoggerFactory.getLogger(ItemServiceImpl.class);

	@Resource
	private ItemDao itemDao;
	
	public ItemServiceOut getMostRecentItems(ItemServiceIn in) {
		Integer itemsNumber = null;
		if (in != null) {
			itemsNumber = in.getItemsNumber();
		}
		ItemServiceOut out = new ItemServiceOut();
		List<ItemRecord> itemRecords = new ArrayList<ItemRecord>();
		itemRecords = itemDao.getMostRecentItems(itemsNumber);
		out.setItemRecords(itemRecords);
		return out;
	}
}
